
	import javax.swing.JPanel;

	import java.awt.*;
	import java.awt.event.*;
import java.awt.geom.*;

	public class monCanvas extends JPanel {
	
		private double  cercle_A ;
		private double  cercle_B ;
		private double  cercle_C ;
		
		public monCanvas(double A, double B, double C)
		{
			 this.cercle_A = A;
			 this.cercle_B = B;
			 this.cercle_C = C;
			
		}
		

		public void paintComponent(Graphics graphics)
	    {
			
			int height = 675;
			int width = 540;
			float[] hsb = new float[3];
					
			if(Fenetre.running)
			{
				
			graphics.setColor(Color.white);
			graphics.fillRect(this.getX(), this.getY(), height, width);
			
			    graphics.setColor(Color.black);
		        graphics.fillOval(20, 50, 300, 300);

		        graphics.setColor(Color.RED);
		        graphics.fillOval(23, 53, 294, 294);
		        
		        
		      //===========cercle A====================
		        
		        
		        Color.RGBtoHSB(150, 218, 244, hsb);
				graphics.setColor(Color.getHSBColor(hsb[0], hsb[1],hsb[2]));
		        graphics.fillOval(170-(int)cercle_A/2, 50, (int)cercle_A, (int)cercle_A);		        
		        graphics.setColor(Color.BLACK);
		        graphics.drawOval(170-(int)cercle_A/2, 50, (int)cercle_A, (int)cercle_A);
  
		      //===========cercle B====================
		        Color.RGBtoHSB(150, 218, 244, hsb);
				graphics.setColor(Color.getHSBColor(hsb[0], hsb[1],hsb[2]));
		        graphics.fillOval(170-(int)cercle_B/2, (int)cercle_A+50,(int)cercle_B, (int)cercle_B);
		        graphics.setColor(Color.BLACK);    
		        graphics.drawOval(170-(int)cercle_B/2, (int)cercle_A+50,(int)cercle_B,(int)cercle_B);
		        
		        //===========cercle C====================
		        Color.RGBtoHSB(150, 218, 244, hsb);
				graphics.setColor(Color.getHSBColor(hsb[0], hsb[1],hsb[2]));
		        graphics.fillOval(170-(int)cercle_C/2, (int)cercle_B+(int)cercle_A+50, (int)cercle_C, (int)cercle_C);
		        graphics.setColor(Color.BLACK);
		        graphics.drawOval(170-(int)cercle_C/2, (int)cercle_B+(int)cercle_A+50, (int)cercle_C, (int)cercle_C);
		        //=====================================
		        
		        //significations
		        graphics.setColor(Color.BLACK);
		        graphics.drawLine(170,50,170,350);
		        
		        //===========signification de grand cercle ====================
		        graphics.drawLine(170,50,470,50);//horizantal 1
		        graphics.drawLine(170,350,470,350);//horizantal 4
		        graphics.drawLine(430,60,430,340);//GRAND = 100 exemple
		        
		        //2eme ligne depart de haut a la fin de cercle A
		        graphics.drawLine(170,(int)cercle_A+50,330,(int)cercle_A+50);//horizantal 2
		        graphics.drawLine(330,60,330,(int)cercle_A + 50 -10);// A= 23 exemple
		        //3eme ligne depart de la fin de cercle A a la fin de cercle B
		        graphics.drawLine(170,(int)cercle_A+50+(int)cercle_B,330,(int)cercle_A+50+(int)cercle_B);//horizantal 3
		        graphics.drawLine(170,(int)cercle_A+50+(int)cercle_B+(int)cercle_C,330,(int)cercle_A+50+(int)cercle_B+(int)cercle_C);//horizantal 4
		        
		        graphics.drawLine(330,(int)cercle_A+50+10,330,(int)cercle_A+50+10+(int)cercle_B-10);//B = 23 exemple
		        
		        graphics.drawLine(330,(int)cercle_A+50 +(int)cercle_B+10,330,(int)cercle_A+50 +(int)cercle_B+ (int)cercle_C-10);//C=23 exemple
		        
				Polygon fleche_Grand_Haut = dessinerFleche(415,40,1 );			 	
				graphics.fillPolygon(fleche_Grand_Haut);
				
				
				Polygon fleche_Grand_Bas = dessinerFleche(415,320,3 );			 	
				graphics.fillPolygon(fleche_Grand_Bas);
				
				Polygon fleche_A_Haut = dessinerFleche(315,40,1);			 	
				graphics.fillPolygon(fleche_A_Haut);
				
				Polygon fleche_A_Bas = dessinerFleche(315,(int)cercle_A + 50 - 30,3);			 	
				graphics.fillPolygon(fleche_A_Bas);
				
				
				Polygon fleche_B_Haut = dessinerFleche(315,(int)cercle_A + 50 - 10,1);			 	
				graphics.fillPolygon(fleche_B_Haut);
				
				Polygon fleche_B_Bas = dessinerFleche(315,(int)cercle_B + (int)cercle_A + 50 - 30, 3);			 	
				graphics.fillPolygon(fleche_B_Bas);
				
				
				Polygon fleche_C_Haut = dessinerFleche(315,(int)cercle_B + (int)cercle_A + 50 - 10,1);			 	
				graphics.fillPolygon(fleche_C_Haut);
				
				Polygon fleche_C_Bas = dessinerFleche(315,(int)cercle_C +(int)cercle_B + (int)cercle_A + 50 - 30,3);			 	
				graphics.fillPolygon(fleche_C_Bas);
				
				
				graphics.setColor(Color.BLUE);
				graphics.drawString("A = ".concat(String.valueOf(cercle_A/3).substring(0, 5)), 340, (int)cercle_A /2 + 50 );
				
				graphics.drawString("B = ".concat(String.valueOf(cercle_B/3).substring(0, 5)), 340, (int)cercle_B/2 + (int)cercle_A + 50);
				
				graphics.drawString("C = ".concat(String.valueOf(cercle_C/3).substring(0, 5)), 340, (int)cercle_C/2 +(int)cercle_B + (int)cercle_A + 50);
				
				graphics.setColor(Color.RED);
				graphics.drawString("100", 440, 230);
				
			}  
	    }
		
		public Polygon dessinerFleche(int x,int y,int degre)
		{
			  //creation une fleche 
	        Dimension size = new Dimension(30,30);
	        
	        Point p1 = new Point(size.width / 3, (2 * size.height) / 3);
			Point p2 = new Point(size.width / 2, degre*size.height / 3);
			Point p3 = new Point((2 * size.width) / 3, (2 * size.height) / 3);

			int[] xs = { p1.x, p2.x, p3.x };
			int[] ys = { p1.y, p2.y, p3.y };
			
			Polygon triangle = new Polygon(xs, ys, xs.length);
			triangle.translate(x,y);
			
			
			return triangle;
			
		}
		
		
		
	
	 
	 
	  
		

	}